package top.tangyh.lamp.care.mapper;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import top.tangyh.basic.base.mapper.SuperMapper;
import top.tangyh.lamp.care.entity.BPipeConfig;
import org.springframework.stereotype.Repository;
import top.tangyh.lamp.care.vo.query.PipeConfigQueryParam;
import top.tangyh.lamp.care.vo.result.PipeConfigGroupDTO;
import top.tangyh.lamp.care.vo.result.PipeConfigGroupOutVO;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * 导管配置表
 * </p>
 *
 * @author zqb
 * @date 2024-07-19 15:02:24
 * @create [2024-07-19 15:02:24] [zqb] [代码生成器生成]
 */
@Repository
public interface BPipeConfigMapper extends SuperMapper<BPipeConfig> {

    default IPage<BPipeConfig> pageYxPipeConfig(PipeConfigQueryParam yxPipeConfigQueryParam) {
        IPage page = new Page();
        page.setSize(yxPipeConfigQueryParam.getSize());
        page.setCurrent(yxPipeConfigQueryParam.getPage());
        LambdaQueryWrapper<BPipeConfig> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(StrUtil.isNotEmpty(yxPipeConfigQueryParam.getIntubationSiteCode()),
                        BPipeConfig::getIntubationSiteCode, yxPipeConfigQueryParam.getIntubationSiteCode())
                .eq(StrUtil.isNotEmpty(yxPipeConfigQueryParam.getTypeCode()),
                        BPipeConfig::getTypeCode, yxPipeConfigQueryParam.getTypeCode())
                .eq(StrUtil.isNotEmpty(yxPipeConfigQueryParam.getPpNameCode()),
                        BPipeConfig::getPpNameCode, yxPipeConfigQueryParam.getPpNameCode())
                .eq(StrUtil.isNotEmpty(yxPipeConfigQueryParam.getPpTypeCode()),
                        BPipeConfig::getPpTypeCode, yxPipeConfigQueryParam.getPpTypeCode())
                .like(StrUtil.isNotEmpty(yxPipeConfigQueryParam.getIntubationSiteName()),
                        BPipeConfig::getIntubationSiteName, yxPipeConfigQueryParam.getIntubationSiteName())
                .like(StrUtil.isNotEmpty(yxPipeConfigQueryParam.getTypeName()),
                        BPipeConfig::getTypeName, yxPipeConfigQueryParam.getTypeName())
                .like(StrUtil.isNotEmpty(yxPipeConfigQueryParam.getPpName()),
                        BPipeConfig::getPpName, yxPipeConfigQueryParam.getPpName())
                .like(StrUtil.isNotEmpty(yxPipeConfigQueryParam.getPpTypeName()),
                        BPipeConfig::getPpTypeName, yxPipeConfigQueryParam.getPpTypeName())
                .eq(null != yxPipeConfigQueryParam.getValidity(),
                        BPipeConfig::getValidity, yxPipeConfigQueryParam.getValidity())
                .eq(null != yxPipeConfigQueryParam.getIsVisiable(),
                        BPipeConfig::getIsVisiable, yxPipeConfigQueryParam.getIsVisiable())
                .eq(null != yxPipeConfigQueryParam.getId(),
                        BPipeConfig::getId, yxPipeConfigQueryParam.getId())
                .orderByDesc(BPipeConfig::getCreatedTime);
        return selectPage(page, queryWrapper);
    }

    default List<BPipeConfig> queryYxPipeConfig(PipeConfigQueryParam yxPipeConfigQueryParam) {
        LambdaQueryWrapper<BPipeConfig> queryWrapper = new LambdaQueryWrapper<>();
        if (null != yxPipeConfigQueryParam) {
            queryWrapper.eq(StrUtil.isNotEmpty(yxPipeConfigQueryParam.getIntubationSiteCode()),
                            BPipeConfig::getIntubationSiteCode, yxPipeConfigQueryParam.getIntubationSiteCode())
                    .eq(StrUtil.isNotEmpty(yxPipeConfigQueryParam.getTypeCode()),
                            BPipeConfig::getTypeCode, yxPipeConfigQueryParam.getTypeCode())
                    .eq(StrUtil.isNotEmpty(yxPipeConfigQueryParam.getPpNameCode()),
                            BPipeConfig::getPpNameCode, yxPipeConfigQueryParam.getPpNameCode())
                    .eq(StrUtil.isNotEmpty(yxPipeConfigQueryParam.getPpTypeCode()),
                            BPipeConfig::getPpTypeCode, yxPipeConfigQueryParam.getPpTypeCode())
                    .like(StrUtil.isNotEmpty(yxPipeConfigQueryParam.getIntubationSiteName()),
                            BPipeConfig::getIntubationSiteName, yxPipeConfigQueryParam.getIntubationSiteName())
                    .like(StrUtil.isNotEmpty(yxPipeConfigQueryParam.getTypeName()),
                            BPipeConfig::getTypeName, yxPipeConfigQueryParam.getTypeName())
                    .like(StrUtil.isNotEmpty(yxPipeConfigQueryParam.getPpName()),
                            BPipeConfig::getPpName, yxPipeConfigQueryParam.getPpName())
                    .like(StrUtil.isNotEmpty(yxPipeConfigQueryParam.getPpTypeName()),
                            BPipeConfig::getPpTypeName, yxPipeConfigQueryParam.getPpTypeName())
                    .eq(null != yxPipeConfigQueryParam.getValidity(),
                            BPipeConfig::getValidity, yxPipeConfigQueryParam.getValidity())
                    .eq(null != yxPipeConfigQueryParam.getIsVisiable(),
                            BPipeConfig::getIsVisiable, yxPipeConfigQueryParam.getIsVisiable())
                    .eq(null != yxPipeConfigQueryParam.getId(),
                            BPipeConfig::getId, yxPipeConfigQueryParam.getId());
        }
        return selectList(queryWrapper);
    }

    List<PipeConfigGroupDTO> queryChannelConfigGroupByPPtype();
}


